home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97a.txt / 000133_icon-group-sender _Wed Jun 11 00:09:36 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Received: from kingfisher.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Wed, 11 Jun 1997 10:41:18 MST
  2. Received: by kingfisher.CS.Arizona.EDU; (5.65v3.2/1.1.8.2/08Nov94-0446PM)
  3.     id AA07916; Wed, 11 Jun 1997 10:41:17 -0700
  4. To: icon-group@cs.arizona.edu
  5. Date: 11 Jun 1997 00:09:36 GMT
  6. From: bbadger@jade.ssd.hcsc.com (Bernard Badger)
  7. Message-Id: <BBADGER.97Jun10200936@jade.ssd.hcsc.com>
  8. Organization: Concurrent Computer Corp, Ft. Lauderdale, FL
  9. Sender: icon-group-request@cs.arizona.edu
  10. References: <Stuart.Robinson-1006972230400001@asianstmg-221.anu.edu.au>
  11. Reply-To: bbadger@mail.ccur.com
  12. Subject: Re: searching with variables
  13. Errors-To: icon-group-errors@cs.arizona.edu
  14. Status: RO
  15. Content-Length: 1517
  16.  
  17. In article <Stuart.Robinson-1006972230400001@asianstmg-221.anu.edu.au> Stuart.Robinson@anu.edu.au (Stuart Robinson) writes:
  18.  
  19.  > A quick question.  If you wanted to use the function find() to search for
  20.  > a particular strings of characters, how would it be possible to define
  21.  > character variables?  For example, suppose you want to search for the
  22.  > following sequences
  23.  > 
  24.  > al
  25.  > el
  26.  > il
  27.  > ol
  28.  > ul
  29.  > 
  30.  > which are really just Vl (where V stands for a vowel).  Could you simply
  31.  > define a character set for vowels (V := 'aeiou') and then refer to that
  32.  > character set in the find() function?  If so, what would it look like?  I
  33.  > tried something like the following and it didn't work.
  34.  > 
  35.  > find( V || "l")
  36.  > 
  37.  > I realise it's a pretty trivial task but I don't have the manual at the
  38.  > moment and I'd like an answer within the next couple of days.  Thanks in
  39.  > advance.
  40.  > 
  41.  > -- 
  42.  > Stuart Robinson <Stuart.Robinson@anu.edu.au>
  43.  > The Australian National University
  44. Well you don't (want to use find()).
  45. Function find() only matches substrings.
  46.  
  47. Try this (based on "The Icon Programming Language" (1983), p 177):
  48. procedure Vl(line)
  49.   static vowel
  50.   local line, i
  51.   initial vowel := 'aeiou'
  52.   i := 1
  53.   while i := upto(vowel,line,i) do {
  54.     suspend line[i+:2]
  55.     i += 2
  56.   }
  57. end
  58.  
  59. procedure testVl()
  60.   local line
  61.   while line := read() do {
  62.     every write(Vl(line))
  63.   }
  64. end
  65.  
  66. Sorry, it's untested and I can't easily test it myself.
  67. --
  68. Bernard A. Badger    bbadger@mail.ccur.com
  69. 11. Thou shalt not Spam!  
  70.